package com.sishuok.jmstest.spring;

import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;
@Service
public class TopicSender {
	@Resource
	private JmsTemplate jmsTemplate;
	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		TopicSender queueSender = ctx.getBean(TopicSender.class);
		queueSender.jmsTemplate.send(new MessageCreator() {
			
			public Message createMessage(Session session) throws JMSException {
				TextMessage msg = session.createTextMessage("Spring msg===");
				return msg;
			}
		});
	}
}
